Welcome To
Jump
Statements


Jump Statements in Python

The jump statement is used to alter the flow of normal execution. and the jump statement is used to move the control from one place to another place . which placed in side the loop and if statements There are three types

  1. Break Statement
  2. Continue statement
  3. Pass statement

Break Statement

The break statement is used to break the execution and exit the execution .

Purpose: Terminates the loop entirely when a specific condition is met.

Syntax

Break

Examples

for i in range(10):
   if i==5:
      break
    print(i)

OutPut

0
1
2
3
4

Continue Statements

The continue statement is a one type of jump statement. it skip the current loop block and continue to the next iteration. the continue statement is used continue the next iteration in the loop. Example in the below

Example

for i in range(10):
    if i==3:
    continue
print(i)

output

0
1
2
4
5
6
7
8
9

Exit() statement

The exit() statement is used to exit the part of the statement. Example in the below

Example

print(" Hello Friends how are you")
   exit()
print("This statement cannot be displayed")

output

Hello Friends how are you

Pass statement

The pass statement is a null statement it does not return the any value . and does not perform the action in the python program . it is only placeholder of future code . it used when the python code does not allow you to place the empty statement in the python code thats way we are using pass keyword to execute the next statement .example in the below

Example

for i in range(1,100):
      if i%2!==0:
pass
Else:
     print(f' {i}is format multiply 2)

Output

2 is format multiply 2
4 is format multiply 2
6 is format multiply 2
8 is format multiply 2
10 is format multiply 2
12 is format multiply 2
14 is format multiply 2
16 is format multiply 2
18 is format multiply 2
20 is format multiply 2
22 is format multiply 2
24 is format multiply 2
26 is format multiply 2
28 is format multiply 2
30 is format multiply 2
32 is format multiply 2
34 is format multiply 2
36 is format multiply 2
38 is format multiply 2
40 is format multiply 2
42 is format multiply 2
44 is format multiply 2
46 is format multiply 2
48 is format multiply 2
50 is format multiply 2
52 is format multiply 2
54 is format multiply 2
56 is format multiply 2
58 is format multiply 2
60 is format multiply 2
62 is format multiply 2
64 is format multiply 2
66 is format multiply 2
68 is format multiply 2
70 is format multiply 2
72 is format multiply 2
74 is format multiply 2
76 is format multiply 2
78 is format multiply 2
80 is format multiply 2
82 is format multiply 2
84 is format multiply 2
86 is format multiply 2
88 is format multiply 2
90 is format multiply 2
92 is format multiply 2
94 is format multiply 2
96 is format multiply 2
98 is format multiply 2